package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.CaptchaVo;
import cn.ywsj.ywsjmidtier.service.CaptchaFeign;
import cn.ywsj.ywsjmidtier.utils.CookiesUtil;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import feign.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Collection;

@Api(tags = "发送短信")
@RestController
@RequestMapping("captcha")
public class CaptchaController {
   @Autowired
   private CaptchaFeign captchaFeign;

    /**
     * 发送验证码
     * @param captchaVo
     * @param result
     * @param session
     * @return
     */
   @ApiOperation("发送短信")
   @PostMapping("sendcode")
   public String sendCode(CaptchaVo captchaVo, BindingResult result, HttpSession session){
      /* MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
       map.add("sysCode",captchaVo.getSysCode());
       map.add("cellphone",captchaVo.getCellphone());
       map.add("type",captchaVo.getType());*/
       JSONObject jsonObject = JsonObjectUtil.ObjectToJson(captchaVo);
       return captchaFeign.sendCode(jsonObject,result,session);
   }

}
